<?php
/**
 * Created by PhpStorm.
 * User: boye009
 * Date: 2016/1/18
 * Time: 10:58
 */

namespace Api\Domain;


use Shop\Api\BannersApi;

class PictureDomain extends BaseDomain{

    protected $business_code = "picture";

    protected $allowType = array("json", "rss", "html");

    /**
     * 获取app轮播图url
     */
    public function getURL(){

        $notes = "应用" . $this->client_id ."调用轮播图获取接口";
        addLog("Picture/", $_GET, $_POST, $notes);
        $this->checkVersion(100);

        if(IS_POST){

            $position = $this -> _post('position',"","缺少position参数");

            $map = array('position'=>$position);//app首页轮播图的position为6013

            $order = "sort asc";

            $result = apiCall(BannersApi::QUERY_NO_PAING,array($map,$order));

            if($result['status']){

                foreach($result['info'] as $k => $v){
                    unset($result['info'][$k]['id']);
                    unset($result['info'][$k]['position']);
                    unset($result['info'][$k]['notes']);
                    unset($result['info'][$k]['uid']);
                    unset($result['info'][$k]['storeid']);
                    unset($result['info'][$k]['createtime']);
                    unset($result['info'][$k]['title']);
                    unset($result['info'][$k]['starttime']);
                    unset($result['info'][$k]['endtime']);
                    unset($result['info'][$k]['noticetime']);
                    unset($result['info'][$k]['sort']);
                    $result['info'][$k]['img_url'] = getImageUrl($result['info'][$k]['img']);
                }

                $this -> apiReturnSuc($result['info']);
            }else{
                $this -> apiReturnErr($result['info']);
            }
        }
    }
}